package com.home.action;

import java.io.IOException;

import javax.servlet.ServletException;
import javax.servlet.annotation.WebServlet;
import javax.servlet.http.HttpServlet;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;

import org.apache.log4j.Logger;

import com.home.util.Buddha;


@WebServlet(asyncSupported = true, urlPatterns = { "/BaseAction" }, loadOnStartup = 1)
public class BaseAction extends HttpServlet {
	private static final long serialVersionUID = 1L;
	private static Logger logger = Logger.getLogger(BaseAction.class); 

    public BaseAction() {
        
    }

    @Override
    public void init() throws ServletException {
    	super.init();
    	Buddha buddha = new Buddha();
    	buddha.print();
    }

	protected void doGet(HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException {
		selectOper(request);
	}


	protected void doPost(HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException {
		selectOper(request);
	}
	
	
	//根据参数oper来选择调用的方法
	private void selectOper(HttpServletRequest request) {
		String oper = request.getParameter("oper");
		switch(oper) {
		case "query":
			query(request);
			break;
		case "add":
			add(request);
			break;
		case "remove":
			remove(request);
			break;
		case "update":
			update(request);
			break;
		default:
			work(request);
		}
	}
	
	public void query(HttpServletRequest request) {
		
	}
	
	public void add(HttpServletRequest request) {
		
	}
	
	public void remove(HttpServletRequest request) {
		
	}
	
	public void update(HttpServletRequest request) {
		
	}
	
	public void work(HttpServletRequest request) {
		
	}

}
